package com.hyf.glidedemo.activity;

import android.os.Bundle;
import android.os.Environment;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.hyf.glidedemo.BaseActivity;
import com.hyf.glidedemo.R;

import java.io.File;

import butterknife.BindView;

public class GlideBaseActivity extends BaseActivity {


    @BindView(R.id.iv_glide_1)
    ImageView image01;
    @BindView(R.id.iv_glide_2)
    ImageView image02;
    @BindView(R.id.iv_glide_3)
    ImageView image03;

    @BindView(R.id.iv_glide_4)
    ImageView image04;

    @BindView(R.id.iv_glide_5)
    ImageView image05;

    @BindView(R.id.iv_glide_6)
    ImageView image06;

    @BindView(R.id.iv_glide_7)
    ImageView image07;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_glide_base);
        setTitle("加载图片的基本操作");
        initData();
    }

    private void initData() {
        // 第一个图片
        Glide.with(this).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1513334993290&di=a39e14614a6d725dd8bde562a6968cf9&imgtype=0&src=http%3A%2F%2Fwapfile.desktx.com%2Fpc%2F161213%2Fbigpic%2F584e0031ab9b4.jpg").into(image01);

        // 加载本地资源图片
        Glide.with(this).load(R.mipmap.local).into(image02);

        // 加载SD卡中图片
        File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "meinv1.jpg");
        Glide.with(this).load(file).into(image03);

        // 加载网络gif
        Glide.with(this).load("http://wx2.sinaimg.cn/mw690/5eef6257gy1fl2b55yo2kg208c069x6p.gif").asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).placeholder(R.mipmap.ic_launcher).into(image04);

        // 加载本地gif
        Glide.with(this).load(new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "meinv2.gif")).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).placeholder(R.mipmap.ic_launcher).into(image05);


        // 加载资源gif
        Glide.with(this).load(R.mipmap.meinv2).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).placeholder(R.mipmap.ic_launcher).into(image06);

        // 加载缩略图
        Glide.with(this).load("https://gss1.bdstatic.com/-vo3dSag_xI4khGkpoWK1HF6hhy/baike/c0%3Dbaike92%2C5%2C5%2C92%2C30/sign=1174c0ef9feef01f591910978197f240/78310a55b319ebc412be0f128926cffc1f171672.jpg").thumbnail(0.1f).centerCrop().into(image07);
    }
}
